import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RelationVO, RelationForm, RelationQuery } from '@/api/cemetery/relation/types';

/**
 * 查询家属信息列表
 * @param query
 * @returns {*}
 */

export const listRelation = (query?: RelationQuery): AxiosPromise<RelationVO[]> => {
  return request({
    url: '/cemetery/relation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询家属信息详细
 * @param id
 */
export const getRelation = (id: string | number): AxiosPromise<RelationVO> => {
  return request({
    url: '/cemetery/relation/' + id,
    method: 'get'
  });
};

/**
 * 新增家属信息
 * @param data
 */
export const addRelation = (data: RelationForm) => {
  return request({
    url: '/cemetery/relation',
    method: 'post',
    data: data
  });
};

/**
 * 修改家属信息
 * @param data
 */
export const updateRelation = (data: RelationForm) => {
  return request({
    url: '/cemetery/relation',
    method: 'put',
    data: data
  });
};

/**
 * 删除家属信息
 * @param id
 */
export const delRelation = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cemetery/relation/' + id,
    method: 'delete'
  });
};
